var hashHistory = ReactRouter.hashHistory;

//定义Header组件
module.exports = React.createClass({
    //第二种跳转方式
    goHome:function () {
        hashHistory.replace('/');
    },
    //定义搜索时事件
    goToSearch:function (e) {
        //判断按键
        if(e.keyCode === 13) {
            //如果是回车键，跳转
            hashHistory.replace('/search/'+e.target.value);
            //清空内容
            e.target.value = '';
            //非约束性组件使用ref
            //约束性组件修改状态
        }
    },

    render:function () {
        return(
            <div className="app-header">
                <header>
                    <div className="container">
                        <input className="pull-right" onKeyDown={this.goToSearch}/>
                        {/*<a href="/">*/}
                        {/*<img src="img/logo.png" alt="" className="logo pull-left"/>*/}
                        {/*</a>*/}
                        <img src="img/logo.png" alt="" className="logo pull-left" onClick={this.goHome}/>
                        <ul className="nav nav-pills nav-justified">
                            <li>
                                <a href="#/type/movie">视频</a>
                            </li>
                            <li>
                                <a href="#/type/games">游戏</a>
                            </li>
                            <li>
                                <a href="#/type/news">新闻</a>
                            </li>
                            <li>
                                <a href="#/type/sports">体育</a>
                            </li>
                            <li>
                                <a href="#/type/buy">购物</a>
                            </li>
                            <li>
                                <a href="#/type/friends">社交</a>
                            </li>
                        </ul>
                    </div>
                </header>
                <div className="banner banner-2"></div>
            </div>
        )
    }
})